home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / TZSET.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  782 b   |  26 lines

  1. /* tzset.c        Turbo C Bible Functions, p. 339     */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <time.h>
  5. extern char *tzname[2];
  6. main()
  7. {
  8.     time_t tnow;
  9.     if(putenv("TZ=EST5EDT")== -1)
  10.         /* Set the envirnoment variable TZ to Eastern Standard
  11.          * Time with daylight saving enabled.  See text for
  12.          * information on defining TZ. */
  13.     {
  14.         printf("Error defining TZ\n");
  15.         exit(1);
  16.     }
  17.         /* Now call "tzset" to set up internal global variables    */
  18.     tzset();
  19.         /* Print the current values of the global variables*/
  20.     printf("timezone = %ld, daylight = %d, \n"
  21.         "tzname[0] = %s\ntzname[1] = %s\n", timezone, daylight,
  22.                             tzname[0], tzname[1]);
  23.         /* Get and display current local time -- should be EDT */
  24.     time(&tnow);
  25.     printf("Local time = %s", ctime(&tnow));
  26. }